﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using Maticsoft.Common;
using LTP.Accounts.Bus;
namespace Hermes.Web.Orders
{
    public partial class Add : Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
                       
        }

        		protected void btnSave_Click(object sender, EventArgs e)
		{
			
			string strErr="";
			if(this.txtOrderNumber.Text.Trim().Length==0)
			{
				strErr+="OrderNumber不能为空！\\n";	
			}
			if(!PageValidate.IsNumber(txtStatus.Text))
			{
				strErr+="Status格式错误！\\n";	
			}
			if(!PageValidate.IsDateTime(txtOrderTime.Text))
			{
				strErr+="OrderTime格式错误！\\n";	
			}
			if(!PageValidate.IsDecimal(txtAmount.Text))
			{
				strErr+="Amount格式错误！\\n";	
			}
			if(!PageValidate.IsNumber(txtSiteID.Text))
			{
				strErr+="SiteID格式错误！\\n";	
			}
			if(!PageValidate.IsDateTime(txtAddTime.Text))
			{
				strErr+="AddTime格式错误！\\n";	
			}
			if(this.txtContact.Text.Trim().Length==0)
			{
				strErr+="Contact不能为空！\\n";	
			}
			if(this.txtCompany.Text.Trim().Length==0)
			{
				strErr+="Company不能为空！\\n";	
			}
			if(this.txtStreet.Text.Trim().Length==0)
			{
				strErr+="Street不能为空！\\n";	
			}
			if(this.txtCity.Text.Trim().Length==0)
			{
				strErr+="City不能为空！\\n";	
			}
			if(this.txtProvince.Text.Trim().Length==0)
			{
				strErr+="Province不能为空！\\n";	
			}
			if(this.txtCountry.Text.Trim().Length==0)
			{
				strErr+="Country不能为空！\\n";	
			}
			if(this.txtCountryCode.Text.Trim().Length==0)
			{
				strErr+="CountryCode不能为空！\\n";	
			}
			if(this.txtPostcode.Text.Trim().Length==0)
			{
				strErr+="Postcode不能为空！\\n";	
			}
			if(this.txtPhone.Text.Trim().Length==0)
			{
				strErr+="Phone不能为空！\\n";	
			}
			if(this.txtEmail.Text.Trim().Length==0)
			{
				strErr+="Email不能为空！\\n";	
			}
			if(this.txtTrackCode.Text.Trim().Length==0)
			{
				strErr+="TrackCode不能为空！\\n";	
			}
			if(!PageValidate.IsDateTime(txtModifyOn.Text))
			{
				strErr+="ModifyOn格式错误！\\n";	
			}
			if(!PageValidate.IsNumber(txtShippingMethod.Text))
			{
				strErr+="ShippingMethod格式错误！\\n";	
			}
			if(!PageValidate.IsNumber(txtStoreID.Text))
			{
				strErr+="StoreID格式错误！\\n";	
			}
			if(!PageValidate.IsDateTime(txtShippingOn.Text))
			{
				strErr+="ShippingOn格式错误！\\n";	
			}
			if(this.txtShippingBy.Text.Trim().Length==0)
			{
				strErr+="ShippingBy不能为空！\\n";	
			}
			if(!PageValidate.IsDateTime(txtImportOn.Text))
			{
				strErr+="ImportOn格式错误！\\n";	
			}
			if(this.txtImportBy.Text.Trim().Length==0)
			{
				strErr+="ImportBy不能为空！\\n";	
			}
			if(!PageValidate.IsDateTime(txtLastUpdate.Text))
			{
				strErr+="LastUpdate格式错误！\\n";	
			}
			if(!PageValidate.IsNumber(txtCustomerID.Text))
			{
				strErr+="CustomerID格式错误！\\n";	
			}
			if(!PageValidate.IsNumber(txtPickUpAddressID.Text))
			{
				strErr+="PickUpAddressID格式错误！\\n";	
			}
			if(!PageValidate.IsNumber(txtShipFromAddressID.Text))
			{
				strErr+="ShipFromAddressID格式错误！\\n";	
			}

			if(strErr!="")
			{
				MessageBox.Show(this,strErr);
				return;
			}
			string OrderNumber=this.txtOrderNumber.Text;
			int Status=int.Parse(this.txtStatus.Text);
			DateTime OrderTime=DateTime.Parse(this.txtOrderTime.Text);
			decimal Amount=decimal.Parse(this.txtAmount.Text);
			int SiteID=int.Parse(this.txtSiteID.Text);
			DateTime AddTime=DateTime.Parse(this.txtAddTime.Text);
			string Contact=this.txtContact.Text;
			string Company=this.txtCompany.Text;
			string Street=this.txtStreet.Text;
			string City=this.txtCity.Text;
			string Province=this.txtProvince.Text;
			string Country=this.txtCountry.Text;
			string CountryCode=this.txtCountryCode.Text;
			string Postcode=this.txtPostcode.Text;
			string Phone=this.txtPhone.Text;
			string Email=this.txtEmail.Text;
			string TrackCode=this.txtTrackCode.Text;
			DateTime ModifyOn=DateTime.Parse(this.txtModifyOn.Text);
			int ShippingMethod=int.Parse(this.txtShippingMethod.Text);
			int StoreID=int.Parse(this.txtStoreID.Text);
			DateTime ShippingOn=DateTime.Parse(this.txtShippingOn.Text);
			string ShippingBy=this.txtShippingBy.Text;
			DateTime ImportOn=DateTime.Parse(this.txtImportOn.Text);
			string ImportBy=this.txtImportBy.Text;
			DateTime LastUpdate=DateTime.Parse(this.txtLastUpdate.Text);
			int CustomerID=int.Parse(this.txtCustomerID.Text);
			int PickUpAddressID=int.Parse(this.txtPickUpAddressID.Text);
			int ShipFromAddressID=int.Parse(this.txtShipFromAddressID.Text);

			Hermes.Model.Orders model=new Hermes.Model.Orders();
			model.OrderNumber=OrderNumber;
			model.Status=Status;
			model.OrderTime=OrderTime;
			model.Amount=Amount;
			model.SiteID=SiteID;
			model.AddTime=AddTime;
			model.Contact=Contact;
			model.Company=Company;
			model.Street=Street;
			model.City=City;
			model.Province=Province;
			model.Country=Country;
			model.CountryCode=CountryCode;
			model.Postcode=Postcode;
			model.Phone=Phone;
			model.Email=Email;
			model.TrackCode=TrackCode;
			model.ModifyOn=ModifyOn;
			model.ShippingMethod=ShippingMethod;
			model.StoreID=StoreID;
			model.ShippingOn=ShippingOn;
			model.ShippingBy=ShippingBy;
			model.ImportOn=ImportOn;
			model.ImportBy=ImportBy;
			model.LastUpdate=LastUpdate;
			model.CustomerID=CustomerID;
			model.PickUpAddressID=PickUpAddressID;
			model.ShipFromAddressID=ShipFromAddressID;

			Hermes.BLL.Orders bll=new Hermes.BLL.Orders();
			bll.Add(model);
			Maticsoft.Common.MessageBox.ShowAndRedirect(this,"保存成功！","add.aspx");

		}


        public void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("list.aspx");
        }
    }
}
